
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>找到100以内的所有素数，并输出</title>
</head>

<body>
    <script>
        for (var i = 2; i <= 100; i++) {

            // 假设它就是素数
            var flag = true
            for (var j = 2; j < i; j++) {

                if (i % j == 0) {
                    flag = false
                    break
                }
            }

            // 要循环完了才能确定是不是质数
            if (flag) {
                console.log(i)
            }
        }
    </script>
</body>

</html>